package com.orhon.smartcampus.modules.base.entity;


import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "base_periods", schema = "smartcloud", catalog = "")
@Slf4j
public class Periods {


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;


    @Column(name = "period_slug", nullable = true, length = 191)
    private String periodSlug;


    @Column(name = "period_number", nullable = true, length = 191)
    private String periodNumber;


    @Column(name = "period_order", nullable = true)
    private Integer periodOrder;


    @Column(name = "created_at", nullable = true)
    private Date createdAt;


    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;


    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;


    @Column(name = "mark", nullable = true, length = 255)
    private String mark;


    @Column(name = "period_name", nullable = true)
    private String periodName;

    @ManyToMany(targetEntity = Subjects.class , mappedBy = "period",  fetch = FetchType.LAZY)
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action= NotFoundAction.IGNORE)
    private List<Subjects> subjects;


}
